<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('become_due', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('user_id')->index()->default(0)->comment('用户ID');
            $table->string('name', 255)->default('')->comment('名称');
            $table->unsignedInteger('price')->default(0)->comment('价格 分');
            $table->unsignedTinyInteger('cycle')->default(0)->comment('周期 0-无 1-天 2-周 3-月 4-年');
            $table->text('svg')->nullable()->comment('图标');
            $table->unsignedTinyInteger('renew')->default(0)->comment('续订 0-不 1-续订');
            $table->unsignedInteger('start_at')->default(0)->comment('开始时间');
            $table->unsignedInteger('end_at')->default(0)->comment('到期时间');
            $table->unsignedTinyInteger('remind_days')->default(7)->comment('提前提醒天数');
            $table->unsignedTinyInteger('status')->default(1)->comment('状态 0-已过期 1-正常 2-已停用');
            $table->text('remark')->nullable()->comment('备注说明');
            $table->unsignedInteger('created_at')->default(0)->comment('创建时间');
            $table->unsignedInteger('updated_at')->default(0)->comment('更新时间');
        });

        // 添加表备注
        DB::statement("ALTER TABLE `become_due` COMMENT '到期提醒'");
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('become_due');
    }
};